home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / libfpvm / pvmftasks.m4 < prev    next >
Text File  |  1997-07-22  |  1KB  |  63 lines

  1.  
  2. /* $Id: pvmftasks.m4,v 1.4 1997/05/07 18:07:32 pvmsrc Exp $ */
  3.  
  4. #include "pvm3.h"
  5. #include "pvm_consts.h"
  6. #include "../src/bfunc.h"
  7.  
  8. void
  9. FUNCTION(pvmftasks)
  10.     ARGS(`where,
  11.         ntaskp,
  12.         tidp,
  13.         ptidp,
  14.         hostp,
  15.         flagp,
  16.         STRING_ARG(a_out),
  17.         infop')
  18.  
  19.     int *where, *ntaskp, *tidp, *ptidp, *hostp, *flagp, *infop;
  20.     STRING_ARG_DECL(a_out);
  21. {
  22.     static struct pvmtaskinfo *tip = 0;
  23.     static int ntask = 0;
  24.     static int next = 0;
  25.  
  26.     int nt;
  27.     int cc;
  28.  
  29. /* if user sets ntaskp to -1 then pvmftasks() will be reset */
  30.  
  31.     if ( ntask && ntaskp && (*ntaskp == -1) )
  32.         ntask = 0;
  33.  
  34.     if ( !ntask ) {
  35.         if ( (cc = pvm_tasks( *where, &nt, &tip )) < 0 ) {
  36.             *infop = cc;
  37.             return;
  38.         }
  39.         ntask = nt;
  40.         next = 0;
  41.     }
  42.  
  43.     if ( next < ntask ) {
  44.         if ( ntaskp ) *ntaskp = ntask;
  45.         if ( tidp ) *tidp = tip[ next ].ti_tid;
  46.         if ( ptidp ) *ptidp = tip[ next ].ti_ptid;
  47.         if ( hostp ) *hostp = tip[ next ].ti_host;
  48.         if ( flagp ) *flagp = tip[ next ].ti_flag;
  49.         if ( STRING_PTR(a_out) )
  50.             ctofstr( STRING_PTR(a_out), STRING_LEN(a_out),
  51.                     tip[ next ].ti_a_out );
  52.         *infop = 1;
  53.         next++;
  54.     }
  55.  
  56. /* cannot return ti_pid without changing interface */
  57. /* users needing this will have to use C           */
  58.  
  59.     if ( next == ntask )
  60.         ntask = 0;
  61. }
  62.  
  63.